import MockAdapter from "axios-mock-adapter";
import http from "@/utils/http";

// 用户操作
import user_login from "@/mock/user_login.json";

// 全局配置
import getGlobalConfig from "@/mock/get_global_config.json";
import getWebsiteScript from "@/mock/get_website_script.json";

// 脚本执行
import postScriptExecute from "@/mock/post_script_execute.json";

// 瀚码标准类目管理
import post_hancode_category from "@/mock/post_hancode_category.json";

// 对齐步骤
import get_process from "@/mock/get_process.json";
import put_process from "@/mock/put_process.json";

const mock = new MockAdapter(http);

if (process.env.VUE_APP_MOCK === "true") {
  // 用户操作
  mock.onPost("/user/login").reply(200, user_login);

  // 全局配置
  mock.onGet("/globals/default").reply(200, getGlobalConfig);
  mock.onGet("/script/list").reply(200, getWebsiteScript);

  // 脚本执行
  mock.onPost("/script/execute").reply(200, postScriptExecute);

  // 瀚码标准类目管理
  mock.onPost("/hancode/categories").reply(200, post_hancode_category);

  // 对齐步骤
  mock.onGet("/process").reply(200, get_process);
  mock.onPut("/process").reply(200, put_process);
}

export default mock;
